/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, Hardware
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "gtest/gtest.h"

#include <cstdio>
#include <cstdlib>
#include <errno.h>
#include <fcntl.h>
#include <fstream>
#include <numeric>
#include <unistd.h>

#include "hmfs_test_utils.h"

using namespace testing;
using namespace testing::ext;

namespace OHOS {
namespace Hmfs {
const std::string F2FS_BINARY_PATH = "/system/bin/mkfs.f2fs";
//const std::string HMFS_BINARY_PATH = "/system/bin/mkfs.f2fs";
const std::string HMFS_BINARY_PATH = "/system/bin/mkfs.hmfs";
const std::string FSCK_BINARY_PATH = "/system/bin/fsck.f2fs";

const std::string STDOUT_OUTPUT_FILE_PATH = "/data/local/";
constexpr uint32_t loopNum = 2000;

class MkfsHmfsMultiTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp() override;
    void TearDown() override;
    static int32_t ExecutableCmd(const char *path, char *const argv[]);
    static int32_t ExecMkfsBinary(std::vector<std::string> &params, const std::string &binaryPath,
        const std::string &outputFile);
    static std::vector<std::string> ConstructCombinationParameters(const std::string &optionGroup,
        const bool containReadOnly = false, const bool changePath = false);
    static void DataDuplicatorDevice(const std::string &devicePath);
    static int32_t RemoveFile(const std::string &removeCommand);
};

void MkfsHmfsMultiTest::SetUpTestCase() {}
void MkfsHmfsMultiTest::TearDownTestCase() {}
void MkfsHmfsMultiTest::SetUp()
{
    for (uint8_t i = 0; i < 4; i++) {
        DataDuplicatorDevice(HMFS_DEVICE_PATH_LIST[i]);
        DataDuplicatorDevice(F2FS_DEVICE_PATH_LIST[i]);
    }
}

int32_t MkfsHmfsMultiTest::RemoveFile(const std::string &removeCommand)
{
    std::vector<char*> argv;
    argv.emplace_back(const_cast<char*>("/bin/sh"));
    argv.emplace_back(const_cast<char*>("-c"));
    argv.emplace_back(const_cast<char*>(removeCommand.c_str()));
    argv.emplace_back(nullptr);
    int32_t res = MkfsHmfsMultiTest::ExecutableCmd(argv[0], argv.data());
    std::cout << "MkfsHmfsMultiTest::RemoveFile removeCommand : " << removeCommand <<
        " res = " << res << std::endl;
    return res;
}

void MkfsHmfsMultiTest::TearDown()
{
    std::cout << "MkfsHmfsMultiTest::TearDown res = " << RemoveFile("rm -rf /data/local/hmfs* /data/local/f2fs*")
        << std::endl;
}

int32_t MkfsHmfsMultiTest::ExecutableCmd(const char *path, char *const argv[])
{
    if (path == nullptr || argv == nullptr ) {
        return -1;
    }

    pid_t pid = fork();
    if (pid < 0) {
        return -errno;
    }

    if (pid == 0) {
        execv(path, argv);
        _exit(EXIT_FAILURE);
    }

    int status = -1;
    pid_t wpid = waitpid(pid, &status, 0);
    if (wpid == -1 || wpid != pid) {
        return -errno;
    }

    if (WIFEXITED(status)) {
        return WEXITSTATUS(status);
    }
    return -ECHILD;
}

int32_t MkfsHmfsMultiTest::ExecMkfsBinary(std::vector<std::string> &params, const std::string &binaryPath,
    const std::string &outputFile)
{
    pid_t pid = fork();
    if (pid < 0) {
        return -errno;
    }

    if (pid == 0) {
        int fd = open(outputFile.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666);
        if (fd < 0) {
            _exit(EXIT_FAILURE);
        }
        dup2(fd, STDOUT_FILENO);
        close(fd);

        std::vector<char*> argv;
        argv.emplace_back(const_cast<char*>(binaryPath.c_str()));
        uint16_t i = 0; 
        for (const auto &param : params) {
            std::cout << " MkfsHmfsMultiTest::ExecMkfsBinary i =  " << i++ << " param = " << param << std::endl;
            argv.emplace_back(const_cast<char*>(param.c_str()));
        }
        argv.emplace_back(nullptr);

        execv(argv[0], argv.data());
        _exit(EXIT_FAILURE);
    }

    int status = -1;
    pid_t wpid = waitpid(pid, &status, 0);
    if (wpid == -1 || wpid != pid) {
        std::cout << " MkfsHmfsMultiTest::ExecMkfsBinary failed -errno =  " << -errno  << std::endl;
        return -errno;
    }

    if (WIFEXITED(status)) {
        int32_t exitStatus = WEXITSTATUS(status);
        std::cout << " MkfsHmfsMultiTest::ExecMkfsBinary failed exitStatus =  " << exitStatus  << std::endl;
        return exitStatus;
    }
    std::cout << " MkfsHmfsMultiTest::ExecMkfsBinary failed -ECHILD =  " << -ECHILD  << std::endl;
    return -ECHILD;
}

void MkfsHmfsMultiTest::DataDuplicatorDevice(const std::string &devicePath)
{
    std::vector<char*> argv;
    argv.emplace_back(const_cast<char*>("/system/bin/dd"));
    argv.emplace_back(const_cast<char*>("if=/dev/zero"));

    std::string outputFile = "of=" + devicePath;
    argv.emplace_back(const_cast<char*>(outputFile.c_str()));
    argv.emplace_back(const_cast<char*>("bs=1M"));
    argv.emplace_back(const_cast<char*>("count=100"));
    argv.emplace_back(nullptr);
    MkfsHmfsMultiTest::ExecutableCmd(argv[0], argv.data());
}

std::vector<std::string> MkfsHmfsMultiTest::ConstructCombinationParameters(const std::string &optionGroup,
    const bool containReadOnly, const bool changePath)
{
    std::vector<std::string> params;
    params.emplace_back("-a 1");
    params.emplace_back("-d 1");

    if (optionGroup.find("-e") != std::string::npos) {
        params.emplace_back("-e cool");
    }

    if (optionGroup.find("-E") != std::string::npos) {
        params.emplace_back("-E hot");
    }

    params.emplace_back("-i");

    if (optionGroup.find("-m") != std::string::npos) {
        params.emplace_back("-m");
    }

    params.emplace_back("-C");
    params.emplace_back("utf8");
    params.emplace_back("-r");
    params.emplace_back("-R 1000:1000");
    params.emplace_back("-s 2");
    params.emplace_back("-t 1");
    params.emplace_back("-T 10086");

    params.emplace_back("-z 2");

    if (optionGroup.find("-O") != std::string::npos) {
        std::string defaultList("-O inode_checksum,flexible_inline_xattr,inode_crtime,lost_found,casefold,"
            "verity,quota,encrypt,sb_checksum,extra_attr,project_quota,compression");
        defaultList += containReadOnly ? ",ro" : "";
        params.emplace_back(defaultList);
    }

    bool contaionWantSecSize = optionGroup.find("-w") != std::string::npos;
    if (contaionWantSecSize) {
        params.emplace_back("-l hmfsTestLablew");
        params.emplace_back("-w 1024");
        if (optionGroup.find("-o") != std::string::npos) {
            params.emplace_back("-o 50");
        }
    }

    if (optionGroup.find("-c") != std::string::npos) {
        params.emplace_back("-l hmfsTestLablec");

        if (optionGroup.find("-o") != std::string::npos) {
            params.emplace_back("-o 20");
        }

        if (changePath) {
            params.emplace_back("-c");
            params.emplace_back(F2FS_DEVICE_PATH_LIST[1]);
            params.emplace_back("-c");
            params.emplace_back(F2FS_DEVICE_PATH_LIST[2]);
            params.emplace_back("-c");
            params.emplace_back(F2FS_DEVICE_PATH_LIST[3]);
        } else {
            params.emplace_back("-c");
            params.emplace_back(HMFS_DEVICE_PATH_LIST[1]);
            params.emplace_back("-c");
            params.emplace_back(HMFS_DEVICE_PATH_LIST[2]);
            params.emplace_back("-c");
            params.emplace_back(HMFS_DEVICE_PATH_LIST[3]);
        }
    }

    params.emplace_back(changePath ? F2FS_DEVICE_PATH_LIST[0] : HMFS_DEVICE_PATH_LIST[0]);

    if (contaionWantSecSize) {
        params.emplace_back("150000");
    }

    return params;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_001
 * @tc.desc: Test the combination parameters, including the -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test001, TestSize.Level1)
{
    std::cout << "Test001 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test001.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-o-O-c", false, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test001.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test001.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-o-O-c", false, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test001.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test001 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test001 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_002
 * @tc.desc: Test the combination parameters, including the -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test002, TestSize.Level1)
{
    std::cout << "Test002 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test002.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-O-c", true, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test002.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test002.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-O-c", true, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test002.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test002 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test002 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_003
 * @tc.desc: Test the combination parameters, including the -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test003, TestSize.Level1)
{
    std::cout << "Test003 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test003.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-E-O-c", false, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test003.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test003.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-E-O-c", false, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test003.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test003 res = " << RemoveFile(rmCmd) << std::endl;
    }
    std::cout << "Test003 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_004
 * @tc.desc: Test the combination parameters, including the -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test004, TestSize.Level1)
{
    std::cout << "Test004 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test004.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-E-O-c", true, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test004.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test004.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-E-O-c", true, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test004.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test004 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test004 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_005
 * @tc.desc: Test the combination parameters, including the -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test005, TestSize.Level1)
{
    std::cout << "Test005 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test005.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-c", false, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test005.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));


    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test005.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-c", false, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test005.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test005 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test005 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_006
 * @tc.desc: Test the combination parameters, including the -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test006, TestSize.Level1)
{
    std::cout << "Test006 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test006.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-c", true, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test006.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test006.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-c", true, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test006.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test006 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test006 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_007
 * @tc.desc: Test the combination parameters, including the -w option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test007, TestSize.Level1)
{
    std::cout << "Test007 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test007.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-O-w", false, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test007.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test007.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-O-w", false, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test007.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test007 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test007 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_008
 * @tc.desc: Test the combination parameters, including the -w option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test008, TestSize.Level1)
{
    std::cout << "Test008 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test008.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-O-w", true, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test008.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test008.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-O-w", true, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test008.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test008 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test008 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_009
 * @tc.desc: Test the combination parameters, including the -w option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test009, TestSize.Level1)
{
    std::cout << "Test009 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test009.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-E-O-w", false, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test009.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test009.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-E-O-w", false, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test009.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test009 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test009 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_010
 * @tc.desc: Test the combination parameters, including the -w option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test010, TestSize.Level1)
{
    std::cout << "Test010 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test010.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-E-O-w", true, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test010.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test010.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-E-O-w", true, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test010.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test010 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test010 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_011
 * @tc.desc: Test the combination parameters, including the -w option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test011, TestSize.Level1)
{
    std::cout << "Test011 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test011.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-w", false, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test011.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test011.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-w", false, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test011.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test011 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test011 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_012
 * @tc.desc: Test the combination parameters, including the -w option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test012, TestSize.Level1)
{
    std::cout << "Test012 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test012.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-w", true, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(0, hmfsRes);

    std::vector<std::string> hmfsDevice { HMFS_DEVICE_PATH_LIST[0] };
    std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test012.txt";
    int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
    EXPECT_EQ(0, fsckHmfsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

    auto hmfsCheckPoint = std::make_unique<CheckPointData>();
    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetCheckPoint(hmfsDevice.at(0), hmfsCheckPoint);
    GetSuperBlock(hmfsDevice.at(0), hmfsSuperBlock);

    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(hmfsDevice.at(0), hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test012.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-w", true, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(0, f2fsRes);

    std::vector<std::string> f2fsDevice { F2FS_DEVICE_PATH_LIST[0] };
    std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test012.txt";
    int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
    EXPECT_EQ(0, fsckF2fsRes);
    ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(f2fsDevice.at(0), f2fsCheckPoint);
    GetSuperBlock(f2fsDevice.at(0), f2fsSuperBlock);

    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(f2fsDevice.at(0), f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    EXPECT_EQ(hmfsAddrIndex, f2fsAddrIndex);

    SuperBlockCode compSB = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    EXPECT_EQ(SUCCESSED_SB, compSB);

    CheckPointCode compCP = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
    EXPECT_EQ(SUCCESSED_CP, compCP);

    NodeDataCode compND = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
    EXPECT_EQ(SUCCESSED_ND, compND);

    if (hmfsRes == 0 && f2fsRes == 0 && compSB == SUCCESSED_SB && compCP == SUCCESSED_CP && compND == SUCCESSED_ND) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test012 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test012 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_013
 * @tc.desc: Test the combination parameters, including the -w -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test013, TestSize.Level1)
{
    std::cout << "Test013 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test013.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-O-w-c", false, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(255, hmfsRes);

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test013.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-O-w-c", false, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(1, f2fsRes);

    if ((hmfsRes == 0) == (f2fsRes == 0)) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test013 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test013 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_014
 * @tc.desc: Test the combination parameters, including the -w -c option.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test014, TestSize.Level1)
{
    std::cout << "Test014 begin" << std::endl;

    std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test014.txt";
    std::vector<std::string> hmfsComParameters = ConstructCombinationParameters("-e-O-w-c", true, false);
    PrintParameters(hmfsComParameters);
    int32_t hmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
    EXPECT_EQ(255, hmfsRes);

    std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test014.txt";
    std::vector<std::string> f2fsComParameters = ConstructCombinationParameters("-e-O-w-c", true, true);
    PrintParameters(f2fsComParameters);
    int32_t f2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
    EXPECT_EQ(1, f2fsRes);

    if ((hmfsRes == 0) == (f2fsRes == 0)) {
        std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
        std::cout << "Test014 res = " << RemoveFile(rmCmd) << std::endl;
    }

    std::cout << "Test014 end" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Combination_015
 * @tc.desc: The test parameter options are random and the parameter option values are also random.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsMultiTest, Test015, TestSize.Level1)
{
    std::cout << "Test015 begin" << std::endl;
    for (uint8_t i = 4; i < MAX_DEVICE_COUNTS - 1; i++) {
        DataDuplicatorDevice(HMFS_DEVICE_PATH_LIST[i]);
        DataDuplicatorDevice(F2FS_DEVICE_PATH_LIST[i]);
    }

    std::srand(std::time(nullptr));
    std::vector<std::string> f2fsComParameters;
    std::vector<std::string> hmfsComParameters;
    for (uint32_t i = 0; i < loopNum; ++i) {
        f2fsComParameters.clear();
        hmfsComParameters.clear();
        f2fsComParameters = GenerateParams(false);
        hmfsComParameters = f2fsComParameters;
        ReplaceDevicePaths(hmfsComParameters);
        PrintParameters(f2fsComParameters);
        PrintParameters(hmfsComParameters);

        std::map<std::string, std::string> parameterMap{};
        bool correct = CheckParametersVaild(f2fsComParameters, parameterMap);
        std::string indexNum = std::to_string(i);
        std::string f2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Test015_" + indexNum + ".txt";
        std::string hmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Test015_" + indexNum + ".txt";

        int32_t f2fsExeRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsComParameters, F2FS_BINARY_PATH, f2fsOutFileName);
        int32_t hmfsExeRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsComParameters, HMFS_BINARY_PATH, hmfsOutFileName);
        // EXPECT_EQ(f2fsExeRes, hmfsExeRes);
        std::cout << "i : " << i << " f2fsExeRes = " << f2fsExeRes << " hmfsExeRes = " << hmfsExeRes << std::endl;
        if (!correct || (f2fsExeRes != 0 && hmfsExeRes != 0)) {
            //预期命令会执行失败
            EXPECT_NE(f2fsExeRes, 0);
            std::string removeCmd = "rm -rf " + hmfsOutFileName + " " + f2fsOutFileName;
            std::cout << "Test015_" << i << " res : " << RemoveFile(removeCmd) << std::endl;
            continue;
        }

        std::string f2fsDevicePath = ConfirmDevicePath(f2fsComParameters);
        std::string hmfsDevicePath = ConfirmDevicePath(hmfsComParameters, false);

        std::cout << "Test015_" << i << " f2fsDevicePath : " << f2fsDevicePath << std::endl;
        std::cout << "Test015_" << i << " hmfsDevicePath : " << hmfsDevicePath << std::endl;

        std::vector<std::string> f2fsDevice { f2fsDevicePath };
        std::string fsckF2fsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_F2fs_Fsck_Test015_" + indexNum + ".txt";
        int32_t fsckF2fsRes = MkfsHmfsMultiTest::ExecMkfsBinary(f2fsDevice, FSCK_BINARY_PATH, fsckF2fsOutFileName);
        EXPECT_EQ(0, fsckF2fsRes);
        ASSERT_TRUE(PrintFsckErrorMsg(fsckF2fsOutFileName, f2fsDevice.at(0)));

        std::vector<std::string> hmfsDevice { hmfsDevicePath };
        std::string fsckHmfsOutFileName = STDOUT_OUTPUT_FILE_PATH + "Mkfs_Hmfs_Fsck_Test015_" + indexNum + ".txt";
        int32_t fsckHmfsRes = MkfsHmfsMultiTest::ExecMkfsBinary(hmfsDevice, FSCK_BINARY_PATH, fsckHmfsOutFileName);
        EXPECT_EQ(0, fsckHmfsRes);
        ASSERT_TRUE(PrintFsckErrorMsg(fsckHmfsOutFileName, hmfsDevice.at(0)));

        auto f2fsCheckPoint = std::make_unique<CheckPointData>();
        auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
        auto f2fsNodeData = std::make_unique<NodeData>();
        GetSuperBlock(f2fsDevicePath, f2fsSuperBlock);
        GetCheckPoint(f2fsDevicePath, f2fsCheckPoint);
        int16_t f2fsAddrIndex = -1;
        GetInodeInfo(f2fsDevicePath, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

        uint32_t f2fsFeatures = GetLeValue(f2fsSuperBlock->features);
        PrintInodeInfo(f2fsFeatures, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

        auto hmfsCheckPoint = std::make_unique<CheckPointData>();
        auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
        auto hmfsNodeData = std::make_unique<NodeData>();
        GetSuperBlock(hmfsDevicePath, hmfsSuperBlock);
        GetCheckPoint(hmfsDevicePath, hmfsCheckPoint);
        int16_t hmfsAddrIndex = -1;
        GetInodeInfo(hmfsDevicePath, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

        uint32_t hmfsFeatures = GetLeValue(hmfsSuperBlock->features);
        PrintInodeInfo(hmfsFeatures, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

        bool mkfsF2fsRes = CheckMkfsHmfsResult(parameterMap, f2fsCheckPoint, f2fsSuperBlock, f2fsNodeData);
        bool mkfsHmfsRes = CheckMkfsHmfsResult(parameterMap, hmfsCheckPoint, hmfsSuperBlock, hmfsNodeData);
        if ((!mkfsF2fsRes) || (!mkfsHmfsRes)) {
            EXPECT_TRUE(false);
            break;
        }

        // 封装对比f2fs和hmfs工具格式化之后的checkPoint和superBlck主要字段值，如果相等，用例成功
        SuperBlockCode supBlkCode = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
        CheckPointCode chkPointCode = CompareCheckPoint(f2fsCheckPoint, hmfsCheckPoint);
        EXPECT_EQ(supBlkCode, SUCCESSED_SB);
        EXPECT_EQ(chkPointCode, SUCCESSED_CP);

        EXPECT_EQ(f2fsAddrIndex, hmfsAddrIndex);
        std::vector<std::string>::const_iterator iter = std::find(f2fsComParameters.begin(),
            f2fsComParameters.end(), "-T");
        NodeDataCode nodeDataCode = ERROR_NODE_UNKNOWN;
        if (iter != f2fsComParameters.end()) {
            nodeDataCode = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, true);
        } else {
            nodeDataCode = CompareNodeData(f2fsNodeData, hmfsNodeData, f2fsAddrIndex, false);
        }
        EXPECT_EQ(nodeDataCode, SUCCESSED_ND);

        if (f2fsExeRes == hmfsExeRes && supBlkCode == SUCCESSED_SB &&
            chkPointCode == SUCCESSED_CP && nodeDataCode == SUCCESSED_ND) {
            std::string rmCmd = "rm -rf " + STDOUT_OUTPUT_FILE_PATH + "Mkfs_*";
            std::cout << "Test015_" << i << " res : " << RemoveFile(rmCmd) << std::endl;
        }
    }

    std::cout << "Test015 end" << std::endl;
}

} // namespace Hmfs
} // namespace OHOS